package hu.bme.mit.androtext.age.ui.wizard.newfile;

import hu.bme.mit.androtext.age.ui.internal.AgeActivator;

import java.io.InputStream;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;

/**
 * AndroGui FileWizardPage that creates a AndroGui file based on the template located in the resources folder.
 * @author Mark Czotter
 *
 */
public class NewAndroGuiFileWizardPage extends WizardNewFileCreationPage {

	public NewAndroGuiFileWizardPage(String pageName,
			IStructuredSelection selection) {
		super(pageName, selection);
		setTitle("New AndroGui File");
		setDescription("Create a new AndroGui file");
		setFileExtension("androgui");
	}
	
	@Override
	protected InputStream getInitialContents() {
		try {
			return FileLocator.openStream(AgeActivator.getInstance().getBundle(), new Path("/resources/newAndroGuiContent.androgui"), false);
        } catch (Exception e) {
            return null; // ignore and create empty content
        }
	}

}
